<?php

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

$root_domain = 'cornish.od.ua';

$layout = false;
$urlManager_rules = array(
//	'search' 		=> 'www/search',
//	'rating' 		=> 'www/rating',
//	'login' 		=> 'www/login',
//	'registration'	=> 'www/registration'
);

switch(!empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : NULL)
{
	case 'admin.' . $root_domain:
		$urlManager_rules = array(
			''				=> 'admin/index',
			'<path:.+>'		=> 'admin/<path>'
		);
		$layout = 'admin';
	break;

	default:
		$urlManager_rules += array(
			''				=> 'www/index',
			'ajax<path:.*>'	=> 'www/ajax/index/<path>',
			'<path:.*>'		=> 'www/page/index/<path>'
		);
	break;
}

return array(
	'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',
	'layout' => $layout,
	'language' => 'ru',
	'sourceLanguage' => 'ru',
	'charset' => 'utf-8',
//	'preload' => array('log'),

	// autoloading model and component classes
	'import' => array(
		'application.models.*',
		'application.components.*',
		'application.components.image.*',
		'application.helpers.*',
		'application.widgets.*',
		'application.extensions.yiidebugtb.*'
	),

	// application components
	'components' => array(
		'urlManager' => array(
			'urlFormat' => 'path',
			'rules' => $urlManager_rules
		),
		'user' => array(
			'class' => 'WebUser',
			'loginUrl' => '/login/',
			'allowAutoLogin' => true,
			'autoRenewCookie' => true,
			'identityCookie' => array(
				'expire' => time() + 86400,
				'domain' => '.' . $root_domain
			)
		),
		'db' => array(
			'connectionString' => 'mysql:host=localhost;dbname=cornish',
			'emulatePrepare' => true,
			'username' => 'root',
			'password' => '',
			'charset' => 'utf8',
			'enableParamLogging' => true
		),
		'authManager'=>array(
			'class'=>'AuthManager'
		),
		'session' => array(
			'sessionName' => 'gId',
			'autoStart' => true,
			'cookieParams' => array(
				'domain' => '.' . $root_domain
			)
		),
/*
		'errorHandler'=>array(
			// use 'site/error' action to display errors
//            'errorAction'=>'index/error',
		),
*/
		'log' => array(
			'class' => 'CLogRouter',
			'routes' => array(
				array(
					'class'=>'CWebLogRoute',
				),
				array(
					'class'=>'CProfileLogRoute',
				),
				array(
					'class' => 'XWebDebugRouter',
					'config' => 'alignLeft, runInDebug, yamlStyle, collapsed',
					'levels' => 'error, warning, trace, profile, info'
				),
			),
		),
	),

	// application-level parameters that can be accessed
	// using Yii::app()->params['paramName']
	'params' => array(
		'DOMAIN_ROOT'			=> $root_domain,
		'DOMAIN'				=> 'http://' . $root_domain . '/',

		'PATH_TO_GROUPS_FILE'	=> '../www/photos/groups.json',
		'PATH_TO_PHOTOS'		=> '../www/photos/',
		'URL_TO_PHOTOS'		=> 'http://' . $root_domain . '/photos/',
		'URL_TO_PHOTOS'		=> 'http://cornish.od.ua/photos/',

		'TABLES' => array(
			'search' => 'search',
			'pages' => 'pages',
		)
	)
);